import 'package:flutter/material.dart';
import 'icon_badge.dart';

class StackDemo extends StatelessWidget {
  const StackDemo({Key key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('StackDemo'),
      ),
      body: Column(
        mainAxisAlignment: MainAxisAlignment.center,
        // crossAxisAlignment: CrossAxisAlignment.center,
        children: <Widget>[
          // SizedBox  如果不设置width height ；SizedBox的大小取决于其子部件的大小
          Stack(
            alignment: Alignment.bottomRight,
            children: <Widget>[
              SizedBox(
                width: 200.0,
                height: 300.0,
                child: Container(
                  alignment: Alignment.topCenter,
                  decoration: BoxDecoration(
                    color: Color.fromRGBO(2, 25, 54, 0.6),
                    borderRadius: BorderRadius.circular(8.0),
                  ),
                  child: Icon(
                    Icons.ac_unit,
                    color: Colors.white,
                    size: 32.0,
                  ),
                ),
              ),

              SizedBox(
                width: 100.0,
                height: 100.0,
                child: Container(
                  decoration: BoxDecoration(
                    color: Color.fromRGBO(2, 25, 54, 0.6),
                    borderRadius: BorderRadius.circular(8.0),
                  ),
                  child: Icon(
                    Icons.ac_unit,
                    color: Colors.white,
                    size: 32.0,
                  ),
                ),
              ),
              // Positioned 要放在stack 里面，类似于绝对定位
              Positioned(
                right: 52.0,
                bottom: 50.0,
                child: IconBadge(Icons.ac_unit),
              ),
            ],
          ),
        ],
      ),
    );
  }
}
